<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>dokumen admin</title>
        <link href="../../script/seminar.css" rel="stylesheet"/>
        <script type="text/javascript" src="../../js/jquery.js"></script>
        <script type="text/javascript" src="../../js/jquery.validate.min.js"></script>
        <script type="text/javascript" src="../../js/script.js"></script>
        <script type="text/javascript">
            function fnLogOut() {
                document.dokumenAdminForm.method = 'POST';
                document.dokumenAdminForm.action = '../../logic/logout.php';
                document.dokumenAdminForm.submit();
            }
            
            function fnSendSms(vNum,vKode,vNoHp,vNama) {
                // revisi
                var vSlctIdx = document.getElementById('slctSMS_'+vNum).selectedIndex;
                var vKodeAlasanSms = document.getElementById('slctSMS_'+vNum)[vSlctIdx].value;
                var vJudul = document.getElementById('hidJudulPaper_'+vNum).value;
                var vWinH = document.body.offsetHeight;
                var vWinW = document.body.offsetWidth;
                var vPopupH = 300;
                var vPopupW = 630;
                var vPosTop = (vWinH-vPopupH)/2;
                var vPosLeft = (vWinW-vPopupW)/2;
                var vURL = "smsForm.php?init=1&kodeSms=" +vKode + "&noHp=" + String(vNoHp) + "&judul=" + vJudul + "&kodeAlasanSms=" + vKodeAlasanSms + "&namaPengirim=" + vNama;
                var vName = "SMS Form";
                var vSpecs = "width="+vPopupW+", height="+vPopupH+", top="+vPosTop+", left="+vPosLeft+", titlebar=no, menubar=no, status=no, resizable=no";
                window.open(vURL, vName, vSpecs);
            }
            
            function fnRefresh() {
                location.reload();
            }
            
            function fnChangeList() {
                var vSlctIdx = document.dokumenAdminForm.slctTopik.selectedIndex;
                var vTopikId = document.dokumenAdminForm.slctTopik[vSlctIdx].value;
                document.dokumenAdminForm.hidTopikId.value = vTopikId;
                document.dokumenAdminForm.method = 'POST';
                document.dokumenAdminForm.action = '../../logic/getListDokumen.php';
                document.dokumenAdminForm.submit();
            }
        </script>
    </head>
    <body>
        <?php
        include("../../utility/connection.php");
        include("../../utility/general.php");
        include("../../model/mPaper.php");
        include("../../model/mSMS.php");
        include("../../model/mSeminar.php");
        
        session_start();
        if (isset($_SESSION['arrResult'])) {
            $arrResult = $_SESSION['arrResult'];
        ?>
        <form name="dokumenAdminForm" id="dokumenAdminForm">
            <input type="hidden" name="hidTopikId" id="hidTopikId" />
        <table border="0" width="100%" height="100%">
            <tr valign="middle">
                <td align="center">
                    
                    <table width="90%" border="0" cellpadding="2" cellspacing="0">
                        <tr>
                            <td>Filter:&nbsp;
                                <select name="slctTopik" id="slctTopik" onchange="fnChangeList()">
                                    <option value="0">Semua&nbsp;Topik</option>
                                    <?php
                                    $topikId = '';
                                    if (isset($_SESSION['topikId'])) {
                                        $topikId = $_SESSION['topikId'];
                                    }
                                                
                                    $resultSeminar = fnInfoSeminarAktif();
                                    if ($resultSeminar) {
                                        while($rowSeminar = mysql_fetch_row($resultSeminar)){
                                    ?>
                                    <option value="<?php echo $rowSeminar[0] ?>" <?php echo ($topikId == $rowSeminar[0])? 'SELECTED':'' ?>><?php echo $rowSeminar[1] ?></option>
                                    <?php
                                        }
                                    }
                                    ?>
                                </select>
                            </td>
                        </tr>
                        <tr class="tbl-body">
                            <td>
                                <table width="100%" height="100%" border="0" cellpadding="5" cellspacing="1">
                                    <tr class="tbl-header">
                                        <!--<td rowspan="3">No</td>-->
                                        <td rowspan="3">Tema Seminar</td>
                                        <td rowspan="3">Nama User</td>
                                        <td rowspan="3">ID Paper</td>
                                        <td>Tgl Upload</td>
                                        <td>Nama File</td>
                                        <td>Judul</td>
                                        <td>Nama Reviewer</td>
                                        <td>Tgl Review</td>
                                        <td>Nilai</td>
                                        <td rowspan="3">Action</td>
                                    </tr>
                                    <tr class="tbl-header">
                                        <td colspan="6">Ringkasan</td>
                                    </tr>
                                    <tr class="tbl-header">
                                        <td colspan="6">Catatan Reviewer</td>
                                    </tr>
                                    <?php
                                    $resultFileInfo = '';
                                    
                                    if (isset($_SESSION['topListResult']))  {
                                        if (intval($topikId) > 0) {
                                            $resultFileInfo = fnGetListFileByIdSeminar($topikId);
                                        } else if (intval($topikId) == 0) {
                                            $resultFileInfo = fnGetListFile();
                                        }
                                    } else if ((!isset($_SESSION['topListResult'])) && (!isset($_SESSION['topikId']))) {
                                        $resultFileInfo = fnGetListFile();
                                    }
                                    
                                    if ($resultFileInfo) {
                                        $num = 1;
                                        
                                        $IDSeminarM = '';
                                        $IDUserM = '';
                                        $IDPaperM = '';
                                        
                                        $IDSeminar = '';
                                        $IDUser = '';
                                        $IDPaper = '';
                                        
                                        $FlagColor = 1;
                                        $IdSeminarColor = '';
                                        $IdUserColor = '';
                                        $IdPaperColor = '';
                                        $hiddenButton = '';
                                        
                                        while($rowFileInfo = mysql_fetch_row($resultFileInfo)){
                                            $No = $num;
                                            
                                            // warna background paper
                                            $Cek = $FlagColor % 2;
                                            $Color = 'style="background: lavender;"';
                                            if ($Cek == 1) {
                                                $Color = 'style="background: khaki;"';
                                            }
                                            $FlagColor =  $FlagColor + 1;
                                            
                                            // pengulangan info dan warna background id seminar
                                            $IDSeminar1 = $rowFileInfo[19];
                                            if ($IDSeminar1 <> $IDSeminarM) {
                                                $IDSeminarM = $IDSeminar1;
                                                $IDSeminar = $IDSeminar1;
                                                $IdSeminarColor = 'style="background: lightcyan;"';
                                                $IDUserM = '';
                                            } else {
                                                $IDSeminar = '';
                                            }
                                            
                                            if ($IDSeminar1 == $IDSeminarM) {
                                                $CekIdSeminar = $rowFileInfo[2] % 2;
                                                if ($CekIdSeminar == 1) {
                                                    $IdSeminarColor = 'style="background: lightblue;"';
                                                }
                                            }
                                            
                                            // pengulangan info dan warna background id user
                                            $IDUser1 = $rowFileInfo[15]; 
                                            if ($IDUser1 <> $IDUserM) {
                                                $IDUserM = $IDUser1;
                                                $IDUser = $IDUser1;
                                                $IdUserColor = 'style="background: palegoldenrod;"';
                                            } else {
                                                $IDUser = '';
                                            }
                                            
                                            if ($IDUser1 == $IDUserM) {
                                                $CekIdUser = $rowFileInfo[1] % 2;
                                                if ($CekIdUser == 1) {
                                                    $IdUserColor = 'style="background: palegreen;"';
                                                }
                                            }
                                            
                                            // pengulangan info dan warna background id paper
                                            $IDPaper1 = $rowFileInfo[0];
                                            if ($IDPaper1 <> $IDPaperM) {
                                                $IDPaperM = $IDPaper1;
                                                $IDPaper = $IDPaper1;
                                                $IdPaperColor = 'style="background: darkseagreen;"';
                                                $hiddenButton = '';
                                            } else {
                                                $IDPaper = '';
                                                $hiddenButton = 'style="display: none;"';
                                            }
                                            
                                            if ($IDPaper1 == $IDPaperM) {
                                                $CekIdPaper = $IDPaper % 2;
                                                if ($CekIdPaper == 1) {
                                                    $IdPaperColor = 'style="background: darksalmon;"';
                                                }
                                            }
                                            
                                            $TglUpload = $rowFileInfo[6];
                                            $digitTgl1 = substr($TglUpload,-2,2);
                                            $digitBulan1 = fnConvertMonth(substr($TglUpload,-5,2));
                                            $digitTahun1 = substr($TglUpload,0,4);
                                            $TglUpload1 = $digitTgl1.' '.$digitBulan1.' '.$digitTahun1;
                                            
                                            $NamaFile = $rowFileInfo[7];
                                            $Judul = $rowFileInfo[3];
                                            $Ringkasan = $rowFileInfo[4];
                                            $Remark = $rowFileInfo[5]; // udah gak dipakai
                                            $IDReviewer = $rowFileInfo[11];
                                            $TglReview = $rowFileInfo[12];
                                            $Nilai = $rowFileInfo[13];
                                            $CatatanReviewer = $rowFileInfo[14];
                                            $NamaPengirim = $rowFileInfo[15];
                                            $TelpPengirim = $rowFileInfo[16];
                                            $NamaReviewer = $rowFileInfo[17];
                                            $TelpReviewer = $rowFileInfo[18];
                                            $TemaSeminar = $rowFileInfo[19];
                                            $StatusSeminar = $rowFileInfo[20];
                                    ?>
                                    <tr class="tbl-body">
                                        <!--<td rowspan="3"><?php echo $No ?></td>-->
                                        <td <?php echo $IdSeminarColor ?> rowspan="3"><?php echo $IDSeminar ?></td>
                                        <td <?php echo $IdUserColor ?> rowspan="3"><?php echo $IDUser ?></td>
                                        <td <?php echo $IdPaperColor ?> rowspan="3"><?php echo $IDPaper ?></td>
                                        <td <?php echo $Color ?>><?php echo $TglUpload1 ?></td>
                                        <td <?php echo $Color ?>><?php echo $NamaFile ?></td>
                                        <td <?php echo $Color ?>><?php echo $Judul ?></td>
                                        <td <?php echo $Color ?>><?php echo $NamaReviewer ?></td>
                                        <td <?php echo $Color ?>><?php echo $TglReview ?></td>
                                        <td <?php echo $Color ?>><?php echo $Nilai ?></td>
                                        <td <?php echo $Color ?> rowspan="3"  align="center">
                                            <input style="display: none" type="text" name="hidJudulPaper_<?php echo $num ?>" id="hidJudulPaper_<?php echo $num ?>" value="<?php echo $Judul ?>">
                                            
                                            <div <?php echo $hiddenButton ?>>
                                            <fieldset>
                                            <select name="slctSMS_<?php echo $num ?>" id="slctSMS_<?php echo $num ?>">
                                                <?php
                                                $keteranganSMS = fnGetMasterSMS();
                                                if ($keteranganSMS) {
                                                    while($rowSMS = mysql_fetch_row($keteranganSMS)){
                                                ?>
                                                <option value="<?php echo $rowSMS[1] ?>"><?php echo $rowSMS[2] ?></option>
                                                <?php
                                                    }
                                                }
                                                ?>
                                            </select><br>
                                            <button type="button" style="width: 100px" name="btSmsSpeaker" id="btSmsSpeaker" onclick="fnSendSms(<?php echo $num ?>,1,'<?php echo $TelpPengirim ?>','<?php echo $NamaPengirim ?>')">Receipt</button><br>
                                            </fieldset>
                                            
                                            <button type="button" style="width: 100px" name="btSmsReviewer" id="btSmsReviewer" onclick="fnSendSms(<?php echo $num ?>,2,'<?php echo $TelpReviewer ?>','<?php echo $NamaPengirim ?>')">Notification</button>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td <?php echo $Color ?> colspan="6"><?php echo $Ringkasan ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td <?php echo $Color ?> colspan="6"><?php echo $CatatanReviewer ?></td>
                                    </tr>
                                    <?php
                                            $num = $num + 1;
                                        }
                                    }
                                    ?>
                                </table>
                            </td>
                        </tr>
                    </table>
                    
                </td>
            </tr>
<!--            <tr valign="middle">
                <td align="center">
                    <button type="button" name="btLogOut" id="btLogOut" onclick="fnLogOut()">LogOut</button>
                </td>
            </tr>-->
        </table>
        </form>
        <?php
        }
        ?>
    </body>
</html>
